/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upf.grupE.impl;

import edu.upf.grupE.Entities.Video;
import edu.upf.grupE.Listener;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;

/**
 *
 * @author xday666
 */
public class VideoListResponseListener implements Listener {
    /*this class implements the listener which will be prepared to understand the searchProfile
    Packets.*/

    private IM im;

    /**
     *
     * @param instancem
     */
    public VideoListResponseListener(final IM instancem) {
        im = instancem;
    }

    /**
     * we only work with the packets that are Messages. then we create a new Message
     * that will be the response to the search profile Message.
     * To be sure that the information that arrives to this listener is correct, we
     * print it into the Text Box.
     * Later we send back to the origin a Message containing the same object received.
     * @param packet
     */
    public final void processPacket(final Packet packet) {
        if (packet instanceof Message) {



            Message msg = (Message) packet;


            Video vid = (Video) msg.getProperty("searchResultVideo");
             System.out.println("Recibido video de: " + msg.getFrom());
             im.el.recivedVideoResult(vid, msg.getFrom());

        }
    }
}
